//
//  LGTypeChosedControl.m
//  ligenyun
//
//  Created by Mac on 2018/3/26.
//  Copyright © 2018年 stoneobs@icloud.com. All rights reserved.
//

#import "LGTypeChosedControl.h"
@interface LGTypeChosedControl()

@end
@implementation LGTypeChosedControl

- (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title{
    if (self == [super initWithFrame:frame]) {
        self.title = title;
        [self configSubView];
    }
    return self;
}
#pragma mark --subView
- (void)configSubView{
    [self st_setBorderWith:1 borderColor:TM_lineColor cornerRadius:0];
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(5, 0, self.width - 20, self.height)
                                                     text:self.title
                                                textColor:SecendTextColor
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    self.titleLable = titleLable;
    [self addSubview:titleLable];
    [NSString lableAutoAdjustWitdhWithLabel:titleLable];
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 8, 5)];
    imageView.image = [UIImage imageNamed:@"icon_下拉"];
    [self addSubview:imageView];
    imageView.right = self.width - 5;
    imageView.centerY = self.height / 2;
    
    [self addTarget:self action:@selector(onSelctedControl:) forControlEvents:UIControlEventTouchUpInside];
    
}
- (void)setTitle:(NSString *)title{
    _title = title;
    if (self.titleLable) {
        self.titleLable.text = title;
        [NSString lableAutoAdjustWitdhWithLabel:self.titleLable];
    }

}
#pragma mark --Action Method
- (void)onSelctedControl:(LGTypeChosedControl*)sender{
    if (self.clction) {
        self.clction(sender);
    }
}
@end
